const express = require('express');
const db = require('../uilit/mysql');

const router=express.Router();

// 获取省、市、区三表数据，并将数据传给前端
router.post('/selectAddress',(req,res)=>{
    const sqlpro=`select * from province`;
    const sqlcity=`select * from city`;
    const sqlarea=`select * from area`;
    db.query(sqlpro,(err1,data1)=>{
        if(err1){
            console.log(err1);
        }else{
            db.query(sqlcity,(err2,data2)=>{
                if(err2){
                    console.log(err2);
                }else{
                    db.query(sqlarea,(err3,data3)=>{
                        if(err3){
                            console.log(err3);
                        }else{
                            res.send({province:data1,city:data2,area:data3});
                        }
                    })
                }
            })
        }
    })
})
// 获取行业表数据，并将数据传给前端
router.post('/selectInd',(req,res)=>{
    const sqlind=`select * from industry_category`;
    db.query(sqlind,(err,data)=>{
        if(err){
            console.log(err);
        }else{
            res.send({industry:data});
        }
    })
})

module.exports=router;
